package io.gitee.yth.design.pattern.test.core.pattern.behavioral.iterator.code;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * @author yth
 * @since 2023-04-26-21:23
 */
public class Department extends Organization {

    public Department(String name) {
        this.name = name;
    }

    @Override
    public void printAll() {
        System.out.println("department: " + name);
        forEach(e -> System.out.println(e.getName()));
    }

    @Override
    public Iterator<Organization> iterator() {
        return new NullIterator();
    }

    protected static class NullIterator implements OrgIterator {

        @Override
        public boolean hasNext() {
            return false;
        }

        @Override
        public Organization next() {
            throw new NoSuchElementException();
        }
    }

}
